# -*- coding: utf-8 -*-

"""
@IDE: PyCharm
@FileName: linked list
@Author: JYFelt
@date： 201801111649 
@这里写描述：
"""
__author__ = 'JYFelt'


class jd():
    def __init__(self, data):
        self.data = data
        self.next = None


class Linklist():
    def __init__(self, jd2):
        """设置表头"""
        self.head = jd2
        self.head.next = None
        self.tail = self.head

    def add(self, jd2):
        """增加节点"""
        self.tail.next = jd2
        self.tail = self.tail.next

    def view(self):
        """查找所有节点"""
        jd2 = self.head
        linkstr = ''

        while jd2 is not None:
            # 那些节点不是表尾
            if jd2.next is not None:
                linkstr = linkstr + str(jd2.data) + '-->'
            else:
                linkstr += str(jd2.data)
            jd2 = jd2.next
        print(linkstr)


# 声明节点：
jd1 = jd(7)
jd2 = jd("Hello")
jd3 = jd(8)
# 建立关系
x = Linklist(jd1)
x.add(jd3)
x.add(jd2)
# 查看链表
x.view()